package com.zyh.em.update;

import com.zyh.em.entity.HistoryData;
import com.zyh.em.entity.LoginSuccessData;

import java.util.HashSet;
import java.util.Set;

public class CityUpdate extends AbstractUpdate{
    /**
     * 更新方法
     *
     * @param loginSuccessData 登录成功数据
     * @param historyData      历史数据
     * @param updateChain      更新链
     */
    @Override
    public void update(LoginSuccessData loginSuccessData, HistoryData historyData, UpdateChain updateChain) {
        Set<String> cities = historyData.getCities();
        if (cities==null){
            cities = new HashSet<>();
            historyData.setCities(cities);
        }
        String city = loginSuccessData.getCity();
        cities.add(city);

        updateChain.doUpdate(loginSuccessData, historyData);
    }
}
